package com.atguigu.tingshu.user.config;


import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WeChatMpConfig {


    @Autowired
    private WeChatAccountConfig  weChatAccountConfig;

    @Bean
    public WxMaService wxMaService() {

        WxMaDefaultConfigImpl wxMaConfig = new WxMaDefaultConfigImpl();
        wxMaConfig.setAppid(weChatAccountConfig.getAppId());
        wxMaConfig.setSecret(weChatAccountConfig.getAppSecret());

        System.out.println("微信小程序的ID"+weChatAccountConfig.getAppId()+ "/t微信小程序的密码" + weChatAccountConfig.getAppSecret());

        WxMaServiceImpl wxMaService = new WxMaServiceImpl();
        wxMaService.setWxMaConfig(wxMaConfig);

        return wxMaService;
    }

}
